/*
 * @features: 功能
 * @description: 说明
 * @Date: 2021-09-15 23:37:52
 * @Author: judu233(769471424@qq.com)
 * @LastEditTime: 2021-09-15 23:40:20
 * @LastEditors: judu233
 */
export const number = '(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))';

export const rgba = 'rgb[a]?\\((' + number + '[%]?)\\s*,\\s*(' + number + '[%]?)\\s*,\\s*(' + number + '[%]?)(?:\\s*,\\s*(' + number + '))?\\)';
export const rgbaNoBackRefs = 'rgb[a]?\\((?:' + number + '[%]?)\\s*,\\s*(?:' + number + '[%]?)\\s*,\\s*(?:' + number + '[%]?)(?:\\s*,\\s*(?:' + number + '))?\\)';

export const hsla = 'hsl[a]?\\((' + number + ')\\s*,\\s*(' + number + '[%])\\s*,\\s*(' + number + '[%])(?:\\s*,\\s*(' + number + '))?\\)';
export const hslaNoBackRefs = 'hsl[a]?\\((?:' + number + ')\\s*,\\s*(?:' + number + '[%])\\s*,\\s*(?:' + number + '[%])(?:\\s*,\\s*(?:' + number + '))?\\)';

export const hex3 = '\\#[0-9a-fA-F]{3}';
export const hex6 = '\\#[0-9a-fA-F]{6}';
export const ascending = (a, b) => {
    if (a < b) {
        return -1;
    } else if (a > b) {
        return 1;
    } else {
        return 0;
    }
};

export const descending = (a, b) => {
    return -1 * ascending(a, b);
};
export const extend = Object.assign != null ? Object.assign.bind(Object) : function (tgt) {
    let args = arguments;

    for (let i = 1; i < args.length; i++) {
        let obj = args[i];

        if (obj == null) { continue; }

        let keys = Object.keys(obj);

        for (let j = 0; j < keys.length; j++) {
            let k = keys[j];

            tgt[k] = obj[k];
        }
    }

    return tgt;
};
